package com.winit.cloudlink.message.utils;

import com.winit.cloudlink.common.exception.CloudlinkException;
import com.winit.cloudlink.message.Constants;

import java.io.UnsupportedEncodingException;

public class MessageUtils {
	public static String messageSummary(byte[] bytes) {
		try {
			return new String(bytes
					, 0
					, bytes.length > Constants.MESSAGE_SUMMARY_LENGTH ? Constants.MESSAGE_SUMMARY_LENGTH : bytes.length
					, Constants.DEFAULT_CHARSET);
		} catch (UnsupportedEncodingException e) {
			throw new CloudlinkException(e.getMessage(), e);
		}
	}
}
